package br.com.vibe.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
import br.com.vibe.bean.R;
import br.com.vibe.canonicos.ItemListDesafiosGroup;

public class AdapterListView extends BaseAdapter{

	 private LayoutInflater mInflater;
	    private ArrayList<ItemListDesafiosGroup> itens;
	 
	    public AdapterListView(Context context, ArrayList<ItemListDesafiosGroup> itens) {
	        //Itens que preencheram o listview
	        this.itens = itens;
	        //responsavel por pegar o Layout do item.
	        mInflater = LayoutInflater.from(context);
	    }
	 
	    /**
	     * Retorna a quantidade de itens
	     *
	     * @return
	     */
	    public int getCount() {
	        return itens.size();
	    }
	 
	    /**
	     * Retorna o item de acordo com a posicao dele na tela.
	     *
	     * @param position
	     * @return
	     */
	    public ItemListDesafiosGroup getItem(int position) {
	        return itens.get(position);
	    }
	 
	    /**
	     * Sem implementação
	     *
	     * @param position
	     * @return
	     */
	    public long getItemId(int position) {
	        return position;
	    }
	 
	    public View getView(int position, View view, ViewGroup parent) {
	        
	    	ItemListDesafiosGroup item = itens.get(position);
	        view = mInflater.inflate(R.layout.desafio_item_list, null);
	        
	        ((TextView) view.findViewById(R.id.text)).setText(item.getTexto());
	        ((CheckBox) view.findViewById(R.id.feito)).setChecked(false);
	        //((ImageView) view.findViewById(R.id.dificuldade)).setBackgroundDrawable(d);
	 
	        return view;
	    }
}


